import request from './request.js'

// 获取购物车列表
export function getCartList() {
  return request({
    url: '/Carts/list',
    method: 'get'
  })
}

// 添加商品到购物车
export function addToCart(productId, quantity) {
  return request({
    url: '/Carts/add',
    method: 'post',
    params: {
      productId,
      quantity
    }
  })
}

// 更新购物车商品数量
export function updateCartQuantity(productId, quantity) {
  return request({
    url: '/Carts/update/quantity',
    method: 'put',
    params: {
      productId,
      quantity
    }
  })
}

// 更新商品选中状态
export function updateCartSelected(productId, selected) {
  return request({
    url: '/Carts/update/selected',
    method: 'put',
    params: {
      productId,
      selected
    }
  })
}

// 删除购物车商品
export function deleteCartItem(productId) {
  return request({
    url: '/Carts/delete',
    method: 'delete',
    params: {
      productId
    }
  })
}

// 计算选中商品总价
export function getCartTotal() {
  return request({
    url: '/Carts/total',
    method: 'get'
  })
} 